home *** CD-ROM | disk | FTP | other *** search
Wrap
(*^ ::[paletteColors = 128; currentKernel; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e8, 24, "Times"; ; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L1, e6, 18, "Times"; ; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, L1, e6, 14, "Times"; ; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L1, a20, 18, "Times"; ; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L1, a15, 14, "Times"; ; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L1, a12, 12, "Times"; ; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = input, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L1, 12, "Courier"; ; fontset = output, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5, 12, "Courier"; ; fontset = message, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = print, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = info, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L1, 12, "Courier"; ; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakBelow, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L1, 12, "Courier"; ; fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, L1, 10, "Times"; ; fontset = header, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = Left Header, nohscroll, cellOutline, 12; fontset = footer, inactive, nohscroll, noKeepOnOnePage, preserveAspect, center, M7, L1, 12; fontset = Left Footer, cellOutline, blackBox, 12; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 10, "Times"; ; fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12, "Courier"; ; fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L1, 12; next21StandardFontEncoding; ] :[font = title; inactive; Cclosed; preserveAspect; startGroup; ] Lab 4: Derivatives :[font = text; inactive; preserveAspect; ] Mathematica handles derivatives of functions of several variables the same way it handles derivatives of single-variable functions. Consequently, most of the problems that we solve using partial derivatives can be done by Mathematica. This lab illustrates some of those methods. ;[s] 4:0,0;11,1;223,2;234,3;281,-1; 4:1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = section; inactive; Cclosed; preserveAspect; startGroup; ] Partial Derivatives :[font = text; inactive; preserveAspect; ] A partial derivative is simply a derivative of a function of several variables, where the derivative is taken while all but one of the variables are held constant. Mathematica's notation for partial derivatives is the same as that for ordinary derivatives. ;[s] 3:0,0;165,1;176,2;258,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] This example is Example 2 on page 646 of Stein: :[font = input; preserveAspect; ] f[x_,y_] := x^2y^3 + E^(x^2y) :[font = text; inactive; preserveAspect; ] It's always a good idea to check your definitions: :[font = input; preserveAspect; endGroup; ] f[x,y] :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Now, the partial derivative of f with respect to x (i.e. holding y constant) is: ;[s] 7:0,0;31,1;32,2;49,3;50,4;65,5;66,6;81,-1; 7:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; endGroup; ] D[f[x,y],x] :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] And the partial with respect to y is: ;[s] 3:0,0;32,1;33,2;38,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; endGroup; endGroup; ] D[f[x,y],y] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercises :[font = text; inactive; preserveAspect; ] 1. Exercise 3 on page 648 of Stein. :[font = text; inactive; preserveAspect; endGroup; endGroup; ] 2. Exercise 5 on page 648 of Stein. :[font = section; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] The Gradient Function :[font = text; inactive; preserveAspect; ] The gradient of a function of several variables is simply the vector-valued function whose components are the partial derivatives of the given function. Recall that Mathematica uses braces { } to denote vectors. ;[s] 5:0,0;166,1;177,2;189,3;194,4;213,-1; 5:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] We will define the grad function as a function of f, x, and y. This way, we can change the definition of f without having to redefine the grad symbol. ;[s] 13:0,0;19,1;23,2;51,3;52,4;54,5;55,6;61,7;62,8;107,9;108,10;140,11;144,12;153,-1; 13:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] Clear[f] :[font = text; inactive; preserveAspect; ] We have to "undefine" f first so that it can act as a variable in the grad definition: ;[s] 5:0,0;22,1;24,2;69,3;75,4;87,-1; 5:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] grad[f_,x_,y_] := {D[f[x,y],x],D[f[x,y],y]} :[font = text; inactive; preserveAspect; ] Here, were are assuming that f will always be a function of two variables. ;[s] 3:0,0;28,1;31,2;75,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] grad[f,x,y] :[font = text; inactive; preserveAspect; endGroup; ] Notice that Mathematica has another way of denoting partial derivatives. ;[s] 3:0,0;12,1;23,2;73,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here is a simple example: :[font = input; preserveAspect; ] f[x_,y_] := x^2 y^3 :[font = input; preserveAspect; ] f[x,y] :[font = input; preserveAspect; endGroup; endGroup; ] grad[f,x,y] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercise :[font = text; inactive; preserveAspect; endGroup; endGroup; ] Define the gradient for the function x / Sqrt[x^2 + y^2]. ;[s] 7:0,0;37,1;38,2;46,3;47,4;52,5;53,6;58,-1; 7:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = section; inactive; Cclosed; preserveAspect; startGroup; ] Critical Points :[font = text; inactive; preserveAspect; ] Recall that a critical point of a function is a point where the function's derivative changes sign (positive to negative, or negative to positive). If the derivative is continuous at the critical point, then it must equal zero there. :[font = text; inactive; preserveAspect; ] Critical points are where extrema (maxima and minima) occur. So we can find the extreme values of a function by locating its critical points. For functions of several variables, this means setting all the partial derivatives equal to zero. But that's equivalent to setting the gradient vector equal to zero. :[font = subsection; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's a simple function that has two critical points: :[font = input; preserveAspect; endGroup; ] f[x_,y_] := 3*x*y - x^3 - y^3 :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] We ask Mathematica to set the gradient equal to zero and solve: ;[s] 3:0,0;7,1;18,2;64,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] Solve[grad[f,x,y]==0,{x,y}] :[font = text; inactive; preserveAspect; ] Note that the symbol 0 in the Input statement actually represents the vector (0,0). ;[s] 4:0,0;20,1;23,2;65,3;66,-1; 4:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = text; inactive; preserveAspect; endGroup; ] The answer is a list of four points. The second and third points involve the imaginary constant I (the square root of -1), so these can be discarded. That leaves two points: (1,1) and (0,0). ;[s] 3:0,0;96,1;99,2;193,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Consider the point (0,0). :[font = text; inactive; preserveAspect; ] First check the gradient at the point (0,0) to be sure that it is the zero vector :[font = input; preserveAspect; ] grad[f,x,y] /. {x -> 0, y -> 0} :[font = text; inactive; preserveAspect; endGroup; ] This tells us that both partial derivatives are equal to zero at the point (0,0). :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Now let's take a look at the graph of f near the point (0,0). ;[s] 3:0,0;39,1;40,2;63,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] Plot3D[ f[x,y], {x,-0.2,0.2}, {y,-0.2,0.2}, PlotPoints -> 32 ]; :[font = text; inactive; preserveAspect; ] The two perpendicular lines on this surface that contain the point (0,0,0) are both horizontal. This verifies that the partial derivatives (which equal the slopes of those two lines) are both zero. :[font = text; inactive; preserveAspect; endGroup; ] The graph also shows that the function does not have an extreme value at the critical point (0,0). That point is a "saddle point" on the surface: the graph goes up in some directions and down in others. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] We can also use a contour plot to verify that this critical point is a saddle point: :[font = input; preserveAspect; ] ContourPlot[ f[x,y], {x,-0.2,0.2}, {y,-0.2,0.2}, PlotPoints -> 32 ]; :[font = text; inactive; preserveAspect; endGroup; ] The level curves near the critical point curve out away from the critical point. That is the characteristic "signature" of a saddle point. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Consider the point (1,1). :[font = text; inactive; preserveAspect; ] Again, check the gradient at the point (0,0) to be sure that it is the zero vector :[font = input; preserveAspect; endGroup; ] grad[f,x,y] /. {x -> 1, y -> 1} :[font = text; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] Now examine the graph of f near the point (1,1): ;[s] 3:0,0;25,1;27,2;49,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] Plot3D[ f[x,y], {x,0.8,1.2}, {y,0.8,1.2}, PlotPoints -> 32 ]; :[font = text; inactive; preserveAspect; endGroup; ] This indicates that the function decreases as one moves away from the point in any direction. That suggests that the function has a relative maximum at (1,1). :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Again, a contour plot will shed more light: :[font = input; preserveAspect; ] ContourPlot[ f[x,y], {x,0.8,1.2}, {y,0.8,1.2}, PlotPoints -> 32 ]; :[font = text; inactive; preserveAspect; endGroup; endGroup; ] All the level curves near the critical point are closed curves around the point. This verifies that the point is an extremum (i.e. either a maximum or a minimum). :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercise :[font = text; inactive; preserveAspect; endGroup; endGroup; ] Find and classify the critical points for the function x^3 + 6*x*y - y^3 . :[font = section; inactive; Cclosed; preserveAspect; startGroup; ] Higher Derivatives :[font = text; inactive; preserveAspect; ] A function of two variables has two first derivatives, four second derivatives, eight third derivatives, etc. Mathematica uses consistent notation for these partial derivatives. ;[s] 3:0,0;111,1;122,2;179,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Here's the same example we used in the first section: :[font = input; preserveAspect; endGroup; ] f[x_,y_] := x^2y^3 + E^(x^2y) :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] It's four second partials are: :[font = input; preserveAspect; ] D[f[x,y],x,x] :[font = input; preserveAspect; ] D[f[x,y],x,y] :[font = input; preserveAspect; ] D[f[x,y],y,x] :[font = input; preserveAspect; endGroup; endGroup; ] D[f[x,y],y,y] :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Exercise :[font = text; inactive; preserveAspect; endGroup; endGroup; ] Find the four second partial derivatives of the function x^3 + 6*x*y - y^3 , and verify that D[f [x,y], x, y] = D[f [x,y], y, x]. :[font = section; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] The Second Derivative Test :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] For a function of a single variable, the Second Derivative Test says that, at a critical point, the function has a maximum if the second derivative is negative and its has a minimum if the second derivative is positive. :[font = text; inactive; preserveAspect; endGroup; ] For a function of two variables, the Second Derivative Test works the same way, but only under the further condition that the discriminant of the function is positive. If the discriminant is negative, then the critical point is a saddle point. :[font = subsection; inactive; Cclosed; preserveAspect; startGroup; ] Example :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] First, we'll define the discriminant to ba a function of f, x, and y: ;[s] 7:0,0;57,1;58,2;60,3;61,4;67,5;68,6;70,-1; 7:1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0;1,10,8,Times,2,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] Clear[f] :[font = input; preserveAspect; ] d2[f_,x_,y_] := D[f[x,y],x,x]D[f[x,y],y,y]- D[f[x,y],x,y]^2 :[font = text; inactive; preserveAspect; ] (Recall that this expression is the determinant of the matrix of second partials.) :[font = input; preserveAspect; endGroup; ] d2[f,x,y] :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] Consider again the example from the section on Critical Points: :[font = input; preserveAspect; ] f[x_,y_] := 3*x*y - x^3 - y^3 :[font = text; inactive; preserveAspect; ] Its discriminant function is: :[font = input; preserveAspect; ] d2[f,x,y] :[font = text; inactive; preserveAspect; ] Its value at the critical point (0,0) is: :[font = input; preserveAspect; ] d2[f,x,y] /. {x->0,y->0} :[font = text; inactive; preserveAspect; endGroup; ] The negative discriminant tells us that the critical point is a saddle point, just as the contour plot suggested. :[font = text; inactive; Cclosed; preserveAspect; startGroup; ] The value of the discriminant at the critical point (1,1) is: :[font = input; preserveAspect; ] d2[f,x,y] /. {x->1,y->1} :[font = text; inactive; preserveAspect; ] The positive discriminant tells us that the critical point is an extreme point. :[font = text; inactive; preserveAspect; ] Now, the value of the second partial D[f [x,y], x, x] at this point will tell us whether the extremum is a minimum or a maximum. ;[s] 3:0,0;36,1;54,2;129,-1; 3:1,11,8,Times,0,12,0,0,0;1,10,8,Courier,1,12,0,0,0;1,11,8,Times,0,12,0,0,0; :[font = input; preserveAspect; ] D[f[x,y],x,x] /. {x->1,y->1} :[font = text; inactive; preserveAspect; endGroup; endGroup; ] Just as with functions of a single variable, a negative second derviative tells us that the function has a relative maximum at that critical point. :[font = subsection; inactive; Cclosed; pageBreak; preserveAspect; startGroup; ] Exercise :[font = text; inactive; preserveAspect; endGroup; endGroup; endGroup; ] Find the critical points for the function 4x^2*y + 3x*y^2 - 12x*y, and then use the Second Derivative Test to classify them (minimum, maximum, or saddle point). ^*)